import os
import cv2
import json

path = r'C:\Users\Admin\Desktop\imagedata\reflag'
save_path = r'C:\Users\Admin\Desktop\imagedata\save_retif'
for fname in os.listdir(path):
    with open(os.path.join(path,fname.strip()), 'r', encoding='utf-8') as f:
        data = json.load(f)
        shape = data["shapes"]
        print(fname)
        print(len(shape) == 0)
        if len(data['shapes']) == 0:
            continue
        json.dump(data, open(os.path.join(save_path, fname), 'w', encoding='utf-8'), indent=4)

